class DatasetGenerator:
    def __init__(self, folder_sharp_images,):
        self.__folder_sharp_images = folder_sharp_images
        self.__image_exts = (".jpg", ".png", ".jpeg")

    def set_exts(self, image_exts=(".jpg", ".png", ".jpeg")):
        self.__image_exts = image_exts

    def generate_dataset(self, folder_images_output, number_of_images):
        import random
        from src.AugmentedImage import AugmentedImage
        from src.AugmentedImagesUtil import AugmentedImagesUtil
        import os

        os.makedirs(folder_images_output, exist_ok=True)
        os.makedirs(folder_images_output + "Sharp/", exist_ok=True)
        os.makedirs(folder_images_output + "Blurred/", exist_ok=True)

        images_file_names = AugmentedImagesUtil.get_images_file_names_from_folder(self.__folder_sharp_images,
                                                                                  self.__image_exts)
        done = 0

        while done < number_of_images:
            image_file = random.choice(images_file_names)
            augmented_image = AugmentedImage.from_file(self.__folder_sharp_images + image_file, grayscale=False)
            augmented_image.to_file(folder_images_output + "Sharp/" + str(done) + ".jpg")

            augmented_image.blur_image_random(kernel_size_possibles=[x for x in range(3, 30, 2)])
            augmented_image.to_file(folder_images_output + "Blurred/" + str(done) + ".jpg")

            done += 1
